<nz-row [nzGutter]="[6, 6]">
  <nz-col nzFlex="auto">
    <cvc-entity-select
      [cvcSelectMode]="props.isMultiSelect ? 'multiple' : 'default'"
      [cvcMinSearchStrLength]="props.minSearchStrLength"
      [cvcCustomTemplate]="selectedTemplate"
      [cvcFormControl]="formControl"
      [cvcFormlyAttributes]="field"
      [cvcEntityName]="props.entityName"
      [cvcPlaceholder]="props.placeholder"
      [cvcResults]="result$ | ngrxPush"
      [cvcOptions]="selectOption$ | ngrxPush"
      [cvcShowError]="showError"
      [cvcDisabled]="props.disabled"
      [cvcLoading]="isLoading$ | ngrxPush"
      [cvcSelectOpen]="selectOpen$ | ngrxPush"
      (cvcOnSearch)="onSearch$.next($event)"
      (cvcOnOpenChange)="onOpenChange$ ? onOpenChange$.next($event) : null"
      (cvcSelectComponent)="selectComponent = $event"
      (cvcOnModelChange)="props.change && props.change(field, $event)">
    </cvc-entity-select>
  </nz-col>
  <nz-col nzFlex="50px">
    <button
      type="button"
      nz-button
      nzBlock
      class="manager-button"
    (click)="onShowMgrClick$.next()">
      <span
        nz-icon
        [ngClass]="{
          show: (showMgr$ | ngrxPush),
          hide: !(showMgr$ | ngrxPush)
        }"
        [nzType]="'caret-right'"></span>
      Manager
    </button>
  </nz-col>
  <nz-col
    nzSpan="24"
    class="manager-drawer"
    *ngIf="showMgr$ | ngrxPush">
    <cvc-evidence-manager
      [cvcSelectedIds]="onEid$ | ngrxPush"
      (cvcSelectedIdsChange)="onPopulate$.next($event)"
      [cvcTableSettings]="tableSettingsChange$ | ngrxPush"
      ></cvc-evidence-manager>
  </nz-col>
</nz-row>
<!-- select option templates -->
<!-- result$ updates generate an array of #optionTemplates. entity-tag-field.mixin watches #optionTemplates changes, and attaches each to an NzSelectOptionTemplateInterface object, which are emitted from selectOption$. selectOption$ is passed to <cvc-entity-select> via [cvcOptions] above -->
<ng-container *ngrxLet="onSearch$ as searchString">
  <ng-container *ngFor="let result of result$ | ngrxPush; index as i">
    <ng-template #optionTemplates>
      <cvc-entity-tag
        [cvcDisableLink]="true"
        [cvcCacheId]="result.__typename + ':' + result.id"
        [cvcEmphasize]="searchString"></cvc-entity-tag>
      <!-- <span
            nz-typography
            nzType="secondary">
            ID:
            <span
              nz-typography
              nzType="secondary"
              [innerHtml]="
                result.citationId.toString() | highlightTypeahead : searchString
              "></span>
          </span> -->
    </ng-template>
  </ng-container>
</ng-container>

<!-- selected option item template -->
<!-- displays entity tag, specifying context and mode depending on
    if field is multi-select or single -->
<ng-template
  #selectedTemplate
  let-selected>
  <div class="ant-select-selection-item-content">
    <cvc-entity-tag
      [cvcCacheId]="'EvidenceItem:' + selected.nzValue"
      [cvcContext]="props.isMultiSelect ? 'multi-select-item' : 'select-item'"
      [cvcMode]="props.isMultiSelect ? 'default' : 'closeable'"
      (cvcOnClose)="onTagClose$.next(selected.nzValue)"></cvc-entity-tag>
  </div>
</ng-template>
